The present invention relates to a magnetic disk controller for controlling data transfer between magnetic disk units constituting external storage apparatuses and a main memory unit of a higher rank apparatus and more particularly to data protection in a cache memory for temporarily holding data transferred between the magnetic disk units and the main memory unit.
As compared with a reading speed of information from a magnetic disk and a writing speed of information into the magnetic disk, a reading and writing speed of information to a cache memory constituted by a random access memory (RAM) is vary fast. Accordingly, by adding a cache memory to a magnetic disk controller for controlling data transfer between the magnetic disk units and the higher rank apparatus, an access time to the higher rank apparatus can be reduced greatly.
In this case, when data is read from the magnetic disk units to the higher rank apparatus, a magnetic disk control unit transfers data from a cache memory to the higher rank apparatus directly when the data is stored in the cache memory. When the data is not stored in the cache memory, the higher rank apparatus and a bus are once released after reception of an instruction and the data is then written into the cache memory from the magnetic disk. Thereafter, the higher rank apparatus and the bus are connected again and the data is transferred from the cache memory to the higher rank apparatus.
Further, when data is to be written into the magnetic disk units from the higher rank apparatus, the data is once written into the cache memory without writing the data into the magnetic disk directly and completion of the writing is reported to the higher rank apparatus when the data has been written into the cache memory. Then, the higher rank apparatus and the bus are released and thereafter the data in the cache memory is written into the magnetic disk to thereby shorten an occupancy time of the higher rank apparatus and the bus.
However, when the data is to be written into the magnetic disk units, the data is first written into the cache memory and then completion of the writing is reported to the higher rank apparatus. Accordingly, when a breaker is pulled down or when a plug receptacle is pulled out or when a power supply is suddenly cut off due to a power failure or the like before the data in the cache memory is written into the magnetic disk, he data written in only the cache memory disappears due to the volatility of the RAM used in the cache memory.
In order to cope with such a case, a battery is provided for the backup of the cache memory so that electric power is supplied from the battery to the cache memory directly to protect the data stored in the cache memory. In the prior art, however, a flag is stored to indicate that the data is stored in the cache memory and it is judged whether the cache memory is backed up by the battery or not.
In the conventional magnetic disk controller, if any data is stored in the cache memory when the power supply for the apparatus is cut off, the cache memory is backed up by the battery. Accordingly, even when the power supply is cut off by a main power supply switch (even when it is previously understood that the power supply is cut off), the data in the cache memory is not written into the magnetic disk and the cache memory is backed up by the battery, so that the battery for backup is continued to be used.